<?php
/**
 * Created by PhpStorm.
 * User: WenQing
 * Date: 2017/7/21
 * Time: 12:26
 */

//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);

//查看服务是否运行
echo $redis->ping().'<br/>';

//string
$redis->set('name','wenqing');
$redis->append('name','_test'); //追加

//bit设置
$redis->setBit('wenqing',100,1); // 100天标记为登录
$redis->setBit('wenqing',101,1); // 101天标记为登录
var_dump($redis->bitCount('wenqing'));  //统计登录

echo '<br/>';
print_r($redis->keys('*'));
echo '<br/>';
print_r($redis->dbSize());

echo '<br/>';

//一次设置多个值
$redis->mset([
    'test1' => '1111',
    'test2' => '2222',
    'test3' => '3333',
    'test4' => '4444'
]);

$redis->hSet('hset','name','wenqing');
$redis->hSet('hset','age','27');